package com.example.mybatis.mapper;

import com.example.mybatis.model.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface UserInfoMapper {
    @ResultMap("resultMap")
    @Select("select * from userInfo")
    List<UserInfo> getUserInfoAll();

    @Select("select * from userInfo where delete_flag = #{deleteFlag}")
    List<UserInfo> getUserByDeleteFlag(Integer deleteFlag);

    @Select("select * from userInfo where delete_flag = #{param1} and gender = #{param2}")
    List<UserInfo> getUserByMany(Integer deleteFlag, Integer gender);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into userInfo (username, password, age, gender) values" +
            " (#{username}, #{password}, #{age}, #{gender})")
    Integer insert(UserInfo userInfo);

    @Select("select id, username, password, age, gender, phone, delete_flag " +
            "as deleteFlag , create_time as createTime, update_time as " +
            "updateTime from userInfo")
    List<UserInfo> selectUserInfo();

    @Results(id = "resultMap", value = {
            @Result(column = "delete_flag", property = "deleteFlag"),
            @Result(column = "create_flag", property = "createFlag"),
            @Result(column = "update_flag", property = "updateFlag")
    })
    @Select("select * from userInfo")
    List<UserInfo> selectUserInfo2();

    @Select("select * from userInfo")
    List<UserInfo> selectUserInfo3();


}
